<?php
$oRoute 			= new Yapary_Route_Route(Yapary_SingletonRegistry::getInstance()->oSql);

$oMVCHandlerConfig 	= new Yapary_MVC_MVCConfig(	FRONTEND_ROOT.'model/',
												FRONTEND_ROOT.'view/',
												FRONTEND_ROOT.'controller/',
												FRONTEND_ROOT.'partial/');
$oMVCHandler		= new Yapary_MVC_MVC($oMVCHandlerConfig);

$oMVCHandler->exchange()->oHeader           = $oHeader; // Global Object
$oMVCHandlerConfig->enableEncoding   = true;
//$oMVCHandlerConfig->internalEncoding = 'UTF-8';
$oMVCHandlerConfig->outputEncoding   = 'UTF-8';


// MVC-Konstrukt laden
/*
 * @TODO oRoute anpassen. Im Fehlerfall leere Klasse mit Abfrageroutine exists()
 * @TODO Variablen trennen
 * */
$route = $oRoute->getRoute($_GET['route']);
// echo 'Controller:'.$route->getController().'<br />Action:'.$route->getAction().'<br />View:'.$route->getView();
// exit;

if ($route == NULL) {
	$oMVCHandler->loadMVC('Failure_Failure', 'defaultAction', 'defaultView');
	Yapary_SingletonRegistry::getInstance()->routeName = 'FAILURE_FAILURE';
} else if ($oMVCHandler->loadMVC($route->getController(), $route->getAction(), $route->getView())) {
	Yapary_SingletonRegistry::getInstance()->routeName = $route->getController();
}

// MVC ausfuehren
//echo 'MVC --> '.$route->getController();

// mit getContent() wird das MVC-Ergebnis ausgegeben
//echo $msg.$oMVCHandler->getContent();
